<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
require_once BaseUtil::getModulePath("base")  .  '/controllers/BaseController.php';
require_once BaseUtil::getModulePath('dbgrid') . '/DBGrid.php';
require_once BaseUtil::getModulePath("systemlog")  .  '/services/SystemLogService.php';
require_once BaseUtil::getModulePath("systemlog")  .  '/constants/LogConstant.php';

class SystemLog_SystemLogController extends BaseController {
    public function init() {
        parent::init();
    }

    public function indexAction(){
        $dbgrid = new DBGrid($this->view);
        $dbgrid->setPost($_POST);
        $dbgrid->addFilter(DBGridConstant::FILTER_TYPE_TEXT, "logs-user_id", $this->_translate->translate("operationUser"));
        $dbgrid->addOptionsFilter(DBGridConstant::FILTER_TYPE_SELECT, "logs-action", $this->_translate->translate("operation"),LogConstant::getActionList());
        $dbgrid->addDateFilter("logs-created",$this->_translate->translate("createTime"));
       // $dbgrid->addOptionsFilter(DBGridConstant::FILTER_TYPE_SELECT, "logs-action_type",$this->_translate->translate("operationType"),LogConstant::getTypeList());
        $dbgrid->addValueFilter('logs-is_delete', '0');
        $dbgrid->addFetchTable("logs","*");
       
        $dbgrid->setFilterColNum(5);
        $dbgrid->addFetchColumn("id", $this->_translate->translate("id"),"view");
        $dbgrid->addFetchColumn("action", $this->_translate->translate("operation"),"",LogConstant::getActionList());
      
        $dbgrid->addFetchColumn("user_id", $this->_translate->translate("operationUser"));
       // $dbgrid->addFetchColumn("action_type", $this->_translate->translate("operationType"),"",LogConstant::getTypeList());
        $dbgrid->addFetchColumn("created", $this->_translate->translate("createTime"));
   
        $dbgrid->setSortOrder("created", "DESC");
       
        $dbgrid->setModule('/systemlog/systemlog');
        $dbgrid->setPageTitle($this->_translate->translate("systemLog"));
        $this->view->dbGrid = $dbgrid->render();
    }

    public function viewAction(){
        $id = $this->_getParam('id');
        $systemLogService = new SystemLogService();
        $systemLog=$systemLogService->getSystemLogById($id);
      
       
        $this->view->id = $id;
        $this->view->systemLog=$systemLog;
     
    }

    public function deleteAction(){
        $id = $this->_getParam('id');
        $systemLogService = new SystemLogService();
        $systemLogService->deleteSystemLog($id);
        $this->_redirector->gotoUrl('systemlog/systemlog');
    }

    public function deletesomeAction(){
        $idsStr = HttpUtil::getPostValue("selectIds");
        $ids = explode(",",$idsStr);
        $systemLogService = new SystemLogService();
        $systemLogService->deleteSystemLogs($ids);
        $this->_redirector->gotoUrl("systemlog/systemlog");
    }
}
?>